/*
 * Copyright (c) 2010 Sylvestre Gallon <syl@pmbsd.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <sys/types.h>
#include <sys/queue.h>
#include <objc.h>
#include <rt.h>
#include <class.h>
#include <dispatch.h>
#include <stdlib.h>

void
__objc_exec_class(struct objc_module *module)
{
        static int first_shot = 1;
        struct objc_symtab *symtab;
        Class cl;
        int i;

        symtab = module->symtab;

        if (first_shot) {
                __objc_init_class_hash();
                __objc_init_dispatch_tables();
                first_shot = 0;
        }

        for (i = 0 ; i < symtab->nb_class ; i++) {
                cl = (Class)symtab->defs[i];

                cl->subclass_list = NULL;

                __objc_add_class_in_hash(cl);
                __objc_install_premature_dtable(cl);
                __objc_install_premature_dtable(cl->meta);

        }

        return;
}

void *
__objc_malloc(size_t size)
{
	return malloc(size);
}

void
__objc_free(void *p)
{
	free(p);
}
